import { Injectable } from '@nestjs/common';
import * as TLSSigAPIv2 from 'tls-sig-api-v2';

@Injectable()
export class TencentImService {
  /**
   * 生成用户签名
   * @param uid
   */
  generateUserSig(uid: string) {
    const appId = process.env.TENCENT_IM_APP_ID;
    const secretKey = process.env.TENCENT_IM_SECRET_KEY;
    const expire = 86400 * 180;
    const tlsSigApi = new TLSSigAPIv2.Api(appId, secretKey);
    return tlsSigApi.genSig(uid, expire);
  }
}
